﻿<UserControl 
    x:Class="MyFloridaHouse.libSvUIControls.ColorScale"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
    mc:Ignorable="d"
    d:DesignHeight="29" d:DesignWidth="400">
    
    
    <Grid x:Name="LayoutRoot"   Height="25" Margin="2">
        <Grid.Resources>

            <!--  This is the default ListBox item styel, overrode padding and border thickness to get the color squares to be exactly next to each other-->
            <Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
                <!--<Setter Property="Padding" Value="3"/>-->
                <Setter Property="Padding" Value="0"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="VerticalContentAlignment" Value="Top"/>
                <Setter Property="Background" Value="Transparent"/>
                <!--<Setter Property="BorderThickness" Value="1"/>-->
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="TabNavigation" Value="Local"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <Grid Background="{TemplateBinding Background}">
                                <!-- VSM excluded for readability -->
                                <Rectangle x:Name="fillColor" Fill="#FFBADDE9" RadiusX="1" RadiusY="1" IsHitTestVisible="False" Opacity="0"/>
                                <Rectangle x:Name="fillColor2" Fill="#FFBADDE9" RadiusX="1" RadiusY="1" IsHitTestVisible="False" Opacity="0"/>
                                <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                <Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1" StrokeThickness="1" RadiusX="1" RadiusY="1" Visibility="Collapsed"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition  />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="20" />
        </Grid.ColumnDefinitions>

        <Border  Grid.Column="0" Background="{Binding MinBackground}" Margin="2"></Border>

        <ListBox  Grid.Column="1"  ItemsSource="{Binding ColorScaleSectionList}" Margin="2"  
                  ItemContainerStyle="{StaticResource ListBoxItemStyle1}"
                  ScrollViewer.VerticalScrollBarVisibility="Disabled"
                  >
            
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" Margin="0" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate >
                <DataTemplate>
                    <Border Background="{Binding colorSectionBackground}" Width="{Binding colorSectionWidth}" Height="25" Margin="0" ToolTipService.ToolTip="{Binding colorPercent}" >
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
            
        </ListBox>

        <Border Grid.Column="2"  Background="{Binding MaxBackground}"  Margin="2"></Border>

    </Grid>
</UserControl>
